package kr.co.doriclassic.mypuppystory.alarmpuppy;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.Preference;

public class PreferenceManager extends Preference{
	static SharedPreferences pref;
	public PreferenceManager(Context context) {
		super(context);
		pref = context.getSharedPreferences("saveDate", Context.MODE_PRIVATE);
	}

	
	// 프리프런스 저장 메소드
	public void savePref(String key, Object value) {
		SharedPreferences.Editor edit = pref.edit();
		if (value instanceof Boolean) {
			edit.putBoolean(key, (boolean) value);
		} else {
			edit.putString(key, (String) value);
		}
		edit.commit();
	}// savePref
		// 프리프런스 로딩 메소드

	public Object loadPref(String key, Object value) {
		Object result = null;
		if (value instanceof Boolean) {
			result = pref.getBoolean(key, (boolean) value);
		} else {
			result = pref.getString(key, (String) value);
		}
		return result;
	}// loadPref
	
	public void removePref(String key){
		SharedPreferences.Editor edit = pref.edit();
		edit.remove(key);
		edit.commit();
	}
}
